import React, { useState, useEffect } from 'react'
import {connect} from 'dva';
import { Table, Tag, space,Pagination  } from 'antd';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom'
import { stringify } from 'querystring'
@connect(({cooperativeStore})=>({
    list: cooperativeStore.list,
    BasicInfoId:cooperativeStore.BasicInfoId
}))

export default class ContractListTable extends React.Component{

    state = {
        cooper:[],
        BasicInfoId:''
      };
      componentDidMount(){
        const { dispatch } = this.props;
        dispatch({
            type: 'cooperativeStore/queryCooperative',
            payload:{
                data:{
                    "pageIndex": 1,
                    "pageSize": 3
                  }
            }
        }).then(res => {
            if(res.code==200){
                this.setState({
                    cooper:res.data.queryShopApplyDto.resultList,
                })
            }
        });
    }


    render(){

        const {cooper}=this.state;
        
         const columns = [{
                    title: '序号',
                    dataIndex: 'index',
                    key: 'index',
                    align: 'center'
                },
                {
                    title: '店铺',
                    dataIndex: 'shopId',
                    align: 'center',
                    render: (text,record) => {
                        let query = {
                             BasicInfoId:record.id
                        };
                        console.log("传入子组件的ID",record.id)
                        return (
                            <Link to = {`/CooperativeStore/ServiceManagement/CooperativeListSub?${stringify(query)}`}>
                                
                                { text }
                            </Link>
                        )
                        
                    }
                    
                },
                {
                    title: '资源名称',
                    dataIndex: 'resourcesName',
                    align: 'center'
                },
                {
                    title: '资源类型',
                    dataIndex: 'resourcesType',
                    align: 'center'
                },
                {
                    title: '服务机场',
                    dataIndex: 'serviceAirlineCompany',
                    align: 'center'
                },
                {
                    title: '服务航司',
                    dataIndex: 'serviceAirport',
                    align: 'center'
                },
                {
                    title: '签约时间',
                    dataIndex: 'applyTime',
                    align: 'center'
                },
                {
                    title: '状态',
                    dataIndex: 'signStatus',
                    align: 'center'
                },
                {
                    title: '操作',
                    key: 'action',
                    align: 'center',
                    render: (text, record) => ( 
                        <space size = "middle" >
                            {/* <a> 处理 </a>   */}
                            <Link to = "/CooperativeStore/ServiceManagement/CooerativeListHandle" > 处理 </Link>  
                        </space>
                ),
            },
    ];



        return(
            <div>
                <Table 
        columns = { columns } 
        dataSource = { cooper } 
        pagination={ false } 
        pagination={{  // 分页
            simple: true,
            current: this.state.current,
            total: this.state.total2,
            onChange: this.changePage,
          }}
        /> 
            </div>
        )
    }
}